export function hasClass (el, className) {
  let name = el.className
  let reg = new RegExp('( |^)' + className + '( |$)')
  return reg.test(name)
}

export function addClass(el, className) {
  if (hasClass(el, className)) {
    return false
  }
  let newClass = el.className.split(' ')
  newClass.push(className)
  el.className = newClass.join(' ')
}

export function getData(el, name, val) {
  var exl = 'data-'
  if (val) {
    el.setAttribute(exl + name, val)
  } else {
    return el.getAttribute(exl + name)
  }
}
